package com.heima.search.controller.v1;


import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.search.dtos.HistorySearchDto;
import com.heima.search.service.ApUserSearchService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/api/v1/history")
public class ApUserSearchController {

    //usersearch
    private final ApUserSearchService apUserSearchService;

    /**
     *查看搜索历史
     *
     * @return
     */
    @PostMapping("/load")
    public ResponseResult findUserSearch(){

        log.info("查看搜索历史");

        return apUserSearchService.findUserSearch();
    }



    /**
     *  删除搜索历史
     *
     * @return
     */
    @PostMapping("/del")
    public ResponseResult deleteUserSearch(@RequestBody HistorySearchDto historySearchDto){

        log.info("删除搜索历史,{}",historySearchDto);

        return apUserSearchService.removeUserSearch(historySearchDto);
    }


}
